package com.ostrich.demomvvm.mvvm

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding

abstract class BaseActivity<VDB: ViewDataBinding> : AppCompatActivity() {
    var binding:VDB? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView<VDB>(this,bindLayout())
        initView()
        initListener()
        initData()
    }

    abstract fun bindLayout():Int
    abstract fun initView()
    abstract fun initData()
    abstract fun initListener()

    /**
     * 页面销毁，binding，解决内存泄漏问题
     */
    override fun onDestroy() {
        super.onDestroy()
        if(binding != null){
            binding = null
        }
    }


}